var vm=new Vue({
    el: "#app",
    data:{
        loginForm: {
            username: '',
            password: '',
        },
        rules: {
            username: [
                { required: true, message: '请输入用户名或手机号', trigger: 'blur' },
            ],
            password: [
                { required: true, message: '请输入密码', trigger: 'blur' },
            ]
        }
    },
    methods:{
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    axios({
                        method: "post",
                        url: "/auth.do",
                        params: this.loginForm,
                    }).then(function (res) {
                       let data=res.data;
                        if (data.code == 200) {
                            const loading = vm.$loading({
                                lock: true,
                                text: '登录成功，正在跳转',
                                background: 'rgba(0, 0, 0, 1)'
                            });
                            setTimeout(() => {
                                localStorage.setItem("user", JSON.stringify(data.data));
                                window.location.href="/menu.html"
                                loading.close();
                            }, 2000);
                        }

                    }).catch((e)=>{
                        console.log(e)
                    })
                } else {
                    return false;
                }
            });
        },
        loading() {
            this.load = true;
            setTimeout(() => {
                this.load = false;
                window.parent.location.reload();
            }, 2000);
        },
    },
    mounted:function () {


    }
})
